package com.jjsc.product.controller;

import com.jjsc.common.core.domain.R;
import com.jjsc.common.core.web.controller.BaseController;
import com.jjsc.common.security.annotation.InnerAuth;
import com.jjsc.product.api.domain.ProductSku;
import com.jjsc.product.api.domain.skuPriceVo;
import com.jjsc.product.service.IProductService;
import com.jjsc.product.service.IProductSkuService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: 钟城明
 * @CreateTime: 2025-10-30
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/productSku")
public class ProductSkuController extends BaseController {

    @Autowired
    private IProductSkuService productSkuService;

    @Autowired
    private IProductService productService;

    @InnerAuth
    @Operation(summary = "获取商品sku详情")
    @GetMapping("/getProductSku/{skuId}")
    public R<ProductSku> getProductSku(@PathVariable("skuId") Long skuId) {
        ProductSku productSku = productSkuService.getById(skuId);
        return R.ok(productSku);
    }
    @InnerAuth
    @Operation(summary = "获取cku商品最新价格")
    @GetMapping("/getSkuPrice/{skuId}")
    public R<skuPriceVo> getSkuPrice(@PathVariable("skuId") Long skuId) {
        skuPriceVo skuPrice = productSkuService.getSkuPrice(skuId);
        return R.ok(skuPrice);
    }

    @Operation(summary = "批量获取商品sku最新价格信息")
    @InnerAuth
    @PostMapping(value = "/getSkuPriceList")
    public R<List<skuPriceVo>> getSkuPriceList(@RequestBody List<Long> skuIdList) {
        return R.ok(productSkuService.getSkuPriceList(skuIdList));
    }



}
